import pytest
import logging
import colorlog
from comms.seafile_funcs import seafile_login, seafile_add_new_database

# 获取 token
@pytest.fixture(scope='session')
def get_token():
    print("---" * 10 + '1.1登录鉴权接口' + "----" * 20)
    resp=seafile_login('seafile@admin.com','admin')
    yield resp.json()['token']
#获取资料库的repo_id
@pytest.fixture(scope='session')
def get_repo_id(get_token):
    print("---" * 10 + '1.3新增资料库接口' + "----" * 20)
    resp=seafile_add_new_database(get_token,'128')
    yield resp.json()['repo_id']




@pytest.fixture()
def func1():
    print('司机：搬砖中')
    yield 160
    print('上班结束，今天去吃个烧烤')

@pytest.fixture()
def func2():
    print('主播：搬砖中')
    yield 3800
    print('上班结束，今天晚上去嗨皮')

@pytest.fixture()
def func3():
    print('码农：搬砖中')
    yield 400
    print('上班结束，今天去吃个烧烤')

### 设置日志颜色
# @pytest.fixture(scope='session', autouse=True)
# def configure_logging():
#     # 获取根日志器
#     logger = logging.getLogger()
#     logger.setLevel(logging.INFO)  # 设置日志级别
#
#     # 定义颜色格式
#     formatter = colorlog.ColoredFormatter(
#         fmt='%(log_color)s%(levelname)-8s %(asctime)s [%(name)s:%(lineno)s] : %(message)s',
#         datefmt='%Y-%m-%d %H:%M:%S',
#         log_colors={  # 配置各日志级别的颜色
#             'DEBUG': 'cyan',
#             'INFO': 'green',
#             'WARNING': 'yellow',
#             'ERROR':'red',
#             'CRITICAL':'red,bg_white',
#         }
#     )
    # file_handler = logging.FileHandler('D:\work\python_files\seafile_128\logs\pytest.log')
    # file_handler.setFormatter(formatter)
    # logger.addHandler(file_handler)
    # stream_handler = logging.StreamHandler()
    # stream_handler.setFormatter(formatter)
    # logger.addHandler(stream_handler)